/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tuneViews;

import javax.swing.JLabel;
import javax.swing.JSlider;

/**
 *
 * @author Israel Agyeman-Prempeh
 */
public class Volume extends javax.swing.JFrame {

    /**
     * Creates new form Volume
     */
    public Volume() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        slider = new javax.swing.JSlider();
        close = new javax.swing.JLabel();
        value = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setName("volume"); // NOI18N
        setUndecorated(true);
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                formMousePressed(evt);
            }
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                formMouseDragged(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/volume-down.png"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 0, 24, 40));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/volume-up.png"))); // NOI18N
        jLabel2.setText("jLabel1");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 0, 34, 40));

        slider.setMinorTickSpacing(1);
        slider.setPaintLabels(true);
        slider.setFocusCycleRoot(true);
        slider.setFocusable(false);
        slider.setMaximumSize(new java.awt.Dimension(30, 10));
        slider.setMinimumSize(new java.awt.Dimension(36, 10));
        slider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                sliderMouseMoved(evt);
            }
        });
        getContentPane().add(slider, new org.netbeans.lib.awtextra.AbsoluteConstraints(37, -2, 320, 40));

        close.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/close.png"))); // NOI18N
        close.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                closeMouseClicked(evt);
            }
        });
        getContentPane().add(close, new org.netbeans.lib.awtextra.AbsoluteConstraints(465, 0, -1, -1));

        value.setFont(new java.awt.Font("Digital-7", 1, 40)); // NOI18N
        value.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        value.setText("50");
        value.setAlignmentY(3.0F);
        value.setMaximumSize(new java.awt.Dimension(36, 5));
        value.setMinimumSize(new java.awt.Dimension(36, 5));
        value.setName(""); // NOI18N
        getContentPane().add(value, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, -10, 70, 50));

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void closeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_closeMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_closeMouseClicked

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_formMouseClicked

    /**
     * This part of the code allows free dragging of the component
     *
     * @param evt
     */
    private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
        // TODO add your handling code here:
        int x = evt.getXOnScreen();
        int y = evt.getYOnScreen();
        this.setLocation(x - xMouse, y - yMouse);
    }//GEN-LAST:event_formMouseDragged

    private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
        // TODO add your handling code here:
        xMouse = evt.getX();
        yMouse = evt.getY();
    }//GEN-LAST:event_formMousePressed

    private void sliderMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderMouseMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_sliderMouseMoved

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */

        try {

            javax.swing.UIManager.setLookAndFeel("Nimbus");

        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Volume.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Volume.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Volume.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Volume.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Volume().setVisible(true);
            }
        });
    }

    /**
     * returns the JSlider which is used as the volume control
     *
     * @return Jslider
     */
    public JSlider getSlider() {
        return slider;
    }

    /**
     * returns the close button of the volume control
     *
     * @return JLabel
     */
    public JLabel getClose() {
        return close;
    }

    /**
     * returns the value which displays the level of the volume
     *
     * @return JLabel
     */
    public JLabel getValue() {
        return value;
    }

    private int xMouse, yMouse;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel close;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JSlider slider;
    private javax.swing.JLabel value;
    // End of variables declaration//GEN-END:variables
}
